package com.sentrix.auto.printercenter.presentation.center.dto;

import com.sentrix.auto.printercenter.domain.entity.PrinterTaskEntity;
import com.sentrix.auto.printercenter.infrastructure.util.VOUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.modelmapper.TypeToken;

import java.util.List;
import java.util.stream.Collectors;

@Schema(description = "打印任务")
@Data
public class PrinterTaskResDto {
    @Schema(description = "订单号")
    private String orderNo;
    @Schema(description = "打印机编码")
    private String printerCode;
    @Schema(description = "agent名称")
    private String agentName;
    @Schema(description = "打印机名称")
    private String printerName;
    @Schema(description = "打印任务ID")
    private String taskId;
    @Schema(description = "打印任务状态")
    private String taskStatus;
    @Schema(description = "打印任务状态描述")
    private String taskStatusDesc;
    @Schema(description = "打印任务开始时间")
    private Long gmtPrint;
    @Schema(description = "打印数据")
    private String data;

    public static List<PrinterTaskResDto> fromDomain(List<PrinterTaskEntity> entities) {
        return VOUtil.modelMapper().map(entities, new TypeToken<List<PrinterTaskResDto>>() {
        }.getType());
    }

    public static PrinterTaskResDto fromDomain(PrinterTaskEntity entity) {
        return VOUtil.modelMapper().map(entity, PrinterTaskResDto.class);
    }
}
